
//
//  CourseAfterClassCell.m
//  ShowYork
//
//  Created by hxh on 2020/9/2.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "LessonDetaiAfterClassCell.h"
#import "ExercisesPageModel.h"
@interface LessonDetaiAfterClassCell ()
@property (nonatomic,strong)UIImageView *iconImgView;
@property (nonatomic,strong)UILabel *titleLb;
@property (nonatomic,strong)UILabel *statusLb;
@property (nonatomic,strong)UIButton *coverBtn;
@property (nonatomic,strong)UIImageView *nextImgView;
@end

@implementation LessonDetaiAfterClassCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    self.coverBtn = [[UIButton alloc]init];
    [self.coverBtn addTarget:self action:@selector(confirmMethod) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.coverBtn];
    
    [self.coverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.top.mas_equalTo(self.contentView);
    }];
    
    self.nextImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"course_tag_next"]];
    [self.contentView addSubview:self.nextImgView];
    
    [self.nextImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-16);
        make.centerY.equalTo(self.contentView);
    }];
    
    self.statusLb = [[UILabel alloc]init];
    self.statusLb.textColor = C153;
    self.statusLb.font = font(12);
    [self.contentView addSubview:self.statusLb];
    
    [self.statusLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.nextImgView.mas_left);
    }];
    
    
    self.iconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"course_after_tag"]];
    [self.contentView addSubview:self.iconImgView];
    
    [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(16);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];

    self.titleLb = [[UILabel alloc]init];
    self.titleLb.textColor = RGBA(51, 51, 51, 1);
    self.titleLb.font = font(14);
    [self.contentView addSubview:self.titleLb];
    
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.iconImgView.mas_right).offset(10);
    }];
}

- (void)setModel:(LessonDetailModel *)model{
    _model = model;
    
    self.titleLb.text = @"课后练习卷";
    

    if (model.isAnswerd) {
        self.statusLb.text = @"查看报告";
    }else{
        ExercisesPageModel *itemModel = [ExercisesPageModel getCurrentExercieseById:model.paper.id];
        if (itemModel != nil) {
            self.statusLb.text = @"继续练习";
        }else{
            self.statusLb.text = @"开始练习";
        }
    }
}

- (void)confirmMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didAnswer)]) {
        [self.delegate didAnswer];
    }
}
@end
